package org.callisto.handlers;
import org.callisto.EventType;
import org.callisto.model.Event;
import org.callisto.model.Keyboard;

public class ConsoleOutputHandler extends KeyboardObserver {

	static StringBuffer buffer = new StringBuffer();
	
	public ConsoleOutputHandler(Keyboard keyboard) {
		super(keyboard);
		System.out.println("[Console output handler]");
	}

	@Override
	public void handleEvent(Event event) {
		StringBuffer buffer = new StringBuffer();
		long time = event.getDelay();
		if (event.getStatus() == EventType.NOTE_ON) {
			for (int s=0;s<event.getPressure();s++) buffer.append('=');
		} else {
			for (int s=0;s<time/10;s++) buffer.append('*');
		}
		buffer.append(event.getShortDesc());
		System.out.println(buffer.toString());
	}
}